<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="robots" content="all" />
    <meta http-equiv="imagetoolbar" content="no" />
    <meta http-equiv="pragma" Content="no-cach" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="format-detection" content="telephone=no" />
    <meta http-equiv="keywords" content="" />
    <meta name="author" content="" />
    <meta name="copyright" content="" />
    <meta name="description" content="" />
    <meta name="HandheldFriendly" content="true" />

    <title>我的钱包</title>
    <link rel="stylesheet" href="../css/mui.min.css">
    <link type="text/css" media="all" rel="stylesheet" href="../js/downdata/css/style.css" />
    <link type="text/css" media="all" rel="stylesheet" href="../js/downdata/css/dropload.css">
<style>
    label{
        font-size: 10px!important;
    }
</style>
</head>
<body ontouchstart=""  id="container">
<div class="mui-content">
<header class="tabHead">
    <span class="active">待申请</span>
    <span>待付款</span>
    <span>已付款</span>
    <b class="border"></b>
</header>
    <div style="padding-top: 60%;width: 100%;height: 200px;position: absolute">
        <div id="popover" class="mui-popover" style="width: 98%;margin-left: 1%;margin-right: 1%; transition: opacity 0s!important;">
        <form class="mui-input-group">
            <div class="mui-input-row ">
                <label>开户名称:</label>
                <input type="text" class=" mui-input-clear" placeholder="" id="username">
            </div>
            <div class="mui-input-row ">
                <label>开户银行:</label>
                <input type="text" class=" mui-input-clear" placeholder="" id="kaihuhang">
            </div>
            <div class="mui-input-row ">
                <label>银行卡号:</label>
                <input type="text" class=" mui-input-clear" placeholder="" id="yinhangka">
            </div>

        </form>
        <button type="button" class="mui-btn mui-btn-primary"  onclick="save()" style="width: 100%;height: 35px;">确定</button>
    </div>
    </div>

    <article class="khfxWarp" style="background-color: #fff;margin-bottom: 60px;!important;padding-top: 40px!important;">
    <section class="khfxPane" style="display:block">
    </section>

    <section class="khfxPane">
    </section>

    <section class="khfxPane">
    </section>

</article>
</div>
<div class="footerpage">
</div>
<button type="button" class="mui-btn mui-btn-primary"  id="bottomPopover"  style="width: 80%;height: 35px;float: left;margin-left: 10%;margin-top: 20px;position:fixed; bottom:9%;">提现</button>
<script src="../js/downdata/lib/jquery-2.2.3.min.js"></script>
<script src="../js/cookieutil.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/mui.min.js"></script>
<script src="../js/downdata/lib/dropload.js"></script>
<script src="../js/getUrlParam.js"></script>
</body>
<script>
    var typedata;
    var pagindex=0;
    var pagesize=10;
    var itemIndex = 0;
    var tabLoadEndArray = [false, false, false];
    var tabScroolTopArray = [0, 0, 0];
    $(".headpage").load("head.html");
    $(".footerpage").load("footer.html");
    var remake="";
    var moneytx=0;
    var  userid=getCookie('userid');
    function setdata(obj)
    {//状态:0=客单,1=协助,2=押金，3=提现
        if (obj==0)
        {
            return"客单";
        }
        if (obj==1)
        {
            return"协助";
        }
        if (obj==3)
        {
            return"提现";
        }
        if (obj==4)
        {
            return"红利";
        }
    }
    function getdata(me,itemIndex){
        typedata==itemIndex;
        if (itemIndex ==0) {
            $("#bottomPopover").show();//表示display:block,
        }
        else {
            $("#bottomPopover").hide();//表示display:block,
        }
        typedata==itemIndex;
        var data = {
            userid: userid,
            status:itemIndex,
            pageindex:pagindex,
            pagesize:pagesize
        }
        var result="";
        mui.post('/Salary/findByupopenid', data, function (info) {
            console.log(info);
            var datas = info.object;
            if(datas.length === 0){
                me.lock();
                me.noData();
                me.resetload();
                return;
            }
            else {
                for (var i = 0; i < datas.length; i++) {
                    cold = datas[i];
                    if (cold['status'] == 0) {
                        result += ' <div class="mui-input-row mui-checkbox mui-left" style="height: 60px;border:0.2px solid #EAEAEA">';
                        result += '<label>'+ "订单号:" + cold['orderid']+ "<br>来源:" + setdata(cold['type']) + "&nbsp;&nbsp;&nbsp;&nbsp;金额" + cold['money'] + "元" + "<br>时间：" + cold['createtime'] + '</label>';

                        result += '<input name="checkbox" value="' + cold['money'] + '" type="checkbox"  id="' + cold['id'] + '"/>';
                        result += ' </div>';
                    }

                    if ((cold['status'] == 1 || cold['status'] == 2)&&(cold['orderid']==null||cold['orderid']=="")) {

                        result += ' <div class="mui-input-row mui-checkbox mui-left" style="height: 60px;border:0.2px solid #EAEAEA">';
                        result += '<label>'+ "订单号:" + isnull(cold['orderid'],cold['id'])+ "<br>来源:" + setdata(cold['type']) + "&nbsp;&nbsp;&nbsp;&nbsp;金额" + cold['money'] + "元" + "<br>时间：" + cold['createtime'] + '</label>';
                        result += ' </div>';
                    }
                }
                $('.khfxPane').eq(itemIndex).append(result);
                me.resetload();
                if(datas.length <10){
                    me.$domDown.html(me.opts.domDown.domNoData);
                }
                else {
                    me.$domDown.html(me.opts.domDown.domRefresh);
                }
                pagindex=pagindex+10;
                pagesize=pagesize+10;
            }
        })

    }

    document.getElementById("bottomPopover").addEventListener("tap", function() {
        var ele = document.getElementsByName("checkbox");
        remake="";moneytx=0;
        for (var i = 0; i < ele.length; i++) {
            if(ele[i].checked) {
                if (remake == "" || remake == undefined || remake == null) {
                    remake = ele[i].id;
                } else {
                    remake = remake + "," + ele[i].id;
                }
                if (moneytx == 0) {
                    var cc = new Number(ele[i].value)
                    moneytx = cc;
                } else {
                    var cc = new Number(ele[i].value)
                    moneytx = moneytx + cc;
                }

            }
        }
        if ((remake == "" || remake == undefined || remake == null)||moneytx == "" || moneytx == undefined || moneytx == null)
        {
            mui.toast("请选择需要提现的记录！");
            return;
        }
        mui("#popover").popover('toggle', document.getElementById("div"));
    })

    //判断是否为空
    function isnull(obj,obj0) {
        if (obj==""||obj==null)
        {
            return obj0;
        }
        else {
            return  obj
        }
    }
    function save() {
        var kaihuhang = $("#kaihuhang").val();
        var yinhangka = $("#yinhangka").val();
        var username = $("#username").val();
        if (kaihuhang == "" || kaihuhang == undefined) {
            mui.toast('请输入你的开户行');
            return;
        }
        if (yinhangka == "" || yinhangka == undefined) {
            mui.toast('请输入你的银行卡号！');
            return;
        }
        if (username == "" || username == undefined) {
            mui.toast('请输入你的姓名！');
            return;
        }
        mui.post('/Salary/insertTx',
            {
                userid: userid,
                money: moneytx,
                kaihuhang: kaihuhang,
                yinhangka: yinhangka,
                username:username,
                remake: remake
            },
            function (data) {
                console.log(data);
                if (data.code) {
                    mui.toast('资料提交成功请你等待处理！');
                    window.location.reload();
                }
                else {
                    mui.toast(data.msg);
                }
            }, 'json'
        )
    };

    $(function () {

        var dropload = $('.khfxWarp').dropload({
            scrollArea: window,
            domDown: {
                domClass: 'dropload-down',
                domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
                domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                domNoData: '<div class="dropload-noData">已经没有了..</div>'
            },
            loadDownFn: function (me) {
                typedata++;
                setTimeout(function () {
                    $('.khfxPane').eq(itemIndex).append('    ');
                    getdata(me,itemIndex);
                }, 500);
            }
        });
        $('.tabHead span').on('click', function () {
            var $this = $(this);
            itemIndex = $this.index();
            if (itemIndex!==typedata)
            {
                pagindex=0;
                pagesize=10;
            }
            $('.khfxPane div').remove();
            $(this).addClass('active').siblings('.tabHead span').removeClass('active');
            $('.tabHead .border').css('left', $(this).offset().left + 'px');
            $('.khfxPane').eq(itemIndex).show().siblings('.khfxPane').hide();
            if (!tabLoadEndArray[itemIndex]) {
                dropload.unlock();
                dropload.noData(false);
            } else {
                dropload.lock('down');
                dropload.noData();
            }
            dropload.resetload();
        });
    });


</script>
</html>
